﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DeviceManager.DataAccessLayer;
using DeviceManager.BusinessLogicLayer;

namespace DeviceManagementIT.DevicesManager.DevicesManagement
{
    
    public partial class frmListQuipment : DevExpress.XtraEditors.XtraForm
    {
        DeviceBllOperation unitbll = new DeviceBllOperation();
        public frmListQuipment()
        {
            InitializeComponent();
        }

        private void frmListQuipment_Load(object sender, EventArgs e)
        {
            btnLoad.PerformClick();
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            THIETBI unitDvt = new THIETBI();
            if (grVView.DataRowCount != 0)
            {
                unitDvt.ThietBiID = int.Parse(grVView.GetFocusedRowCellDisplayText("ThietBiID"));
                string message = unitbll.DeleteRecordDevice(unitDvt);
                MessageBox.Show(message, "Message");
                btnLoad.PerformClick();
            }
        }

        private void btnLoad_Click(object sender, EventArgs e)
        {
            List<THIETBI> listunit = unitbll.GetRecordDevice(new THIETBI());
            grCView.DataSource = listunit;
            grVView.Columns[1].Caption = "Mã thiết bị";
            grVView.Columns[2].Caption = "Tên thiết bị";
            grVView.Columns[7].Caption = "Hạng bảo hành";
            grVView.Columns[5].Caption = "Số hiệu";

            grVView.Columns[0].Visible = false;
            grVView.Columns[3].Visible = false;
            grVView.Columns[4].Visible = false;
            grVView.Columns[6].Visible = false;
            grVView.Columns[7].Visible = false;
            grVView.Columns[8].Visible = false;
            grVView.Columns[9].Visible = false;
            grVView.Columns[10].Visible = false;
            grVView.Columns[11].Visible = false;
            grVView.Columns[12].Visible = false;
            grVView.Columns[13].Visible = false;
            grVView.Columns[14].Visible = false;
            grVView.Columns[15].Visible = false;
            grVView.Columns[16].Visible = false;
            grVView.Columns[17].Visible = false;
            grVView.Columns[18].Visible = false;
            grVView.Columns[19].Visible = false;
            grVView.Columns[20].Visible = false;
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmAddDevices m_frmAddevices = new frmAddDevices();
            m_frmAddevices.Show();
        }
    }
}